package com.xxl.job.executor.vehicle.controller;

import com.xxl.job.executor.utils.CameraInfo;
import com.xxl.job.executor.vehicle.service.CustomMultiThreadingService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @description 摄像头控制类
 * @author SONGtiank
 * @Date: 2020/11/4 9:11
 * @Version: 1.0
 */
@Controller
public class CameraController {

    private org.slf4j.Logger logger = LoggerFactory.getLogger(CameraController.class);

    @Autowired
    private CustomMultiThreadingService customMultiThreadingService;

    @ResponseBody
    @RequestMapping(value="/dotask")
    public String doTask() throws InterruptedException{
        Timer timer = new Timer();// 实例化Timer类
        timer.schedule(new TimerTask() {
            public void run() {
                //撤销布防上传通道
                try {
                    customMultiThreadingService.executeAysncTask1(CameraInfo.cameraInfo[0][0]);
                    customMultiThreadingService.executeAsyncTask2(CameraInfo.cameraInfo[1][0]);
                    //customMultiThreadingService.executeAsyncTask3(CameraInfo.cameraInfo[2][0]);
                    //customMultiThreadingService.executeAsyncTask4(CameraInfo.cameraInfo[3][0]);
                    //customMultiThreadingService.executeAsyncTask5(CameraInfo.cameraInfo[4][0]);
                    //customMultiThreadingService.executeAsyncTask6(CameraInfo.cameraInfo[5][0]);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, 1000*60*5,1000*60*5);// 这里毫秒
        customMultiThreadingService.executeAysncTask1(CameraInfo.cameraInfo[0][0]);
        customMultiThreadingService.executeAsyncTask2(CameraInfo.cameraInfo[1][0]);
        //customMultiThreadingService.executeAsyncTask3(CameraInfo.cameraInfo[2][0]);
        //customMultiThreadingService.executeAsyncTask4(CameraInfo.cameraInfo[3][0]);
        //customMultiThreadingService.executeAsyncTask5(CameraInfo.cameraInfo[4][0]);
        //customMultiThreadingService.executeAsyncTask6(CameraInfo.cameraInfo[5][0]);
        return "success";
    }
}